package cn.zhangchg.leetcode.string;

public class ReserveStr {

    public static void main(String[] args) {
        System.out.println(reserveStr("asbs"));
    }

    public static String reserveStr(String str){
        //return Arrays.
        if (str.length() == 1) {
            return str;
        }
        char[] chars = str.toCharArray();

        char[] reserveChars = new char[chars.length];
        int j = 0;
        for (int i = chars.length - 1; i >= 0; i--,j++) {
            reserveChars[j] = chars[i];
        }
        return new String(reserveChars);
    }
}
